import { createWebHashHistory } from 'vue-router';

// import ProgressBarPlugin from './plugin/progress'
// import nestedRouteRenderPlugin from './plugin/nested-route-render-plugin'
import type { App } from 'vue';

const routes = [{
    path: '/test',
    meta: { title: '测试', icon: 'home' },
    children: [{
        path: 'test2',
        meta: { title: '测试2', icon: 'home' },
        children: [{
            path: 'test3',
            component: () => import('@/views/test2.vue'),
            meta: { title: '测试2', icon: 'home' }
        },{
            path: 'test4',
            component: () => import('@/views/test.vue'),
            meta: { title: '测试2', icon: 'home' }
        }]
    }]
}]

// const router = createRouter({
//     history: createWebHashHistory(),
//     routes,
// });


import {
    createRouter,
    nestedRouteRenderPlugin,
} from '@pro/router';

const router = createRouter({
    history: createWebHashHistory(),
    routes: routes,
    plugins: [
        nestedRouteRenderPlugin()
    ],
});


export default {
    install(app: App) {
        // const appRun: ((app: App) => void)[] = [];
        // nestedRouteRenderPlugin(router, (c: (app: App) => void) => {
        //     appRun.push(c);
        // });
        // ProgressBarPlugin(router, {
        //     showSpinner: false,
        //     speed: 200,
        //     minimum: 0.1,
        // })
        // appRun.forEach(c => c(app))
        app.use(router);
    }
};

